<html>
<head><meta charset="utf-8"><title>Is custom allocators the right abstraction? · t-libs/wg-allocators · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/index.html">t-libs/wg-allocators</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html">Is custom allocators the right abstraction?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218178617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218178617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218178617">(Nov 28 2020 at 19:58)</a>:</h4>
<p><strong>matthieum</strong> has started an <a href="https://internals.rust-lang.org/t/is-custom-allocators-the-right-abstraction/13460">interesting proposal at IRL.org</a> which is really worth taking a look at.</p>
<p><strong>TL;DR: </strong><br>
Use a more generic trait for collections, which abstracts over storages rather than allocators.</p>



<a name="218179020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218179020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218179020">(Nov 28 2020 at 20:09)</a>:</h4>
<p>Storage instead of an Allocator as a generic makes sense for contiguous data structures (Vec, Box), but not as much for non-contiguous ones (LinkedList), I think?</p>



<a name="218179076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218179076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218179076">(Nov 28 2020 at 20:10)</a>:</h4>
<p>Agreed</p>



<a name="218179079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218179079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218179079">(Nov 28 2020 at 20:10)</a>:</h4>
<p>But it would be nice to do both</p>



<a name="218179083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218179083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218179083">(Nov 28 2020 at 20:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/197181-t-libs.2Fwg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F/near/218179020">said</a>:</p>
<blockquote>
<p>Storage instead of an Allocator as a generic makes sense for contiguous data structures (Vec, Box), but not as much for non-contiguous ones (LinkedList), I think?</p>
</blockquote>
<p>Interesting question, the OP says, it <em>could</em> be possible.</p>



<a name="218179088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218179088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218179088">(Nov 28 2020 at 20:11)</a>:</h4>
<p>(I wrote a one off ring buffer recently and was sad)</p>



<a name="218179090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218179090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218179090">(Nov 28 2020 at 20:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220594">John Ericson</span> <a href="#narrow/stream/197181-t-libs.2Fwg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F/near/218179079">said</a>:</p>
<blockquote>
<p>But it would be nice to do both</p>
</blockquote>
<p>Like having <code>AllocRef</code> and <code>Storage</code>?</p>



<a name="218179093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218179093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218179093">(Nov 28 2020 at 20:11)</a>:</h4>
<p>That would be simply possible with <code>AllocatorStorage</code> I think.</p>



<a name="218182695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Is%20custom%20allocators%20the%20right%20abstraction%3F/near/218182695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Is.20custom.20allocators.20the.20right.20abstraction.3F.html#218182695">(Nov 28 2020 at 21:47)</a>:</h4>
<p>I'll need to look at the propose, but i mean in vague terms all collections should allow some variation on this front, and the "flat" ones should allow more</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>